Skip to content

Upload existing overrides and CGM events when a remote data service is added - #2713

Open
ps2 wants to merge 1 commit into
next-devfrom
fix/backfill-overrides-cgm-events
Open

ps2 wants to merge 1 commit into
next-devfrom
fix/backfill-overrides-cgm-events

Conversation

@ps2

@ps2 ps2 commented Dec 5, 2026

Copy link
Copy Markdown
Collaborator

When a remote data service is added, uploadExistingData uploads what Loop already has stored, but it skipped overrides and CGM events. Both use the same per-service query anchors as the other types, so a newly added service starts from nil and they would be uploaded in full; they just weren't triggered until something changed.

Tested in the Simulator on next-dev by adding Tidepool after Nightscout had been running: glucose, carbs, doses, dosing decisions, pump events and settings were all backfilled, but the Walking preset that was active when Tidepool was added only reached Tidepool after it was ended. If no override changes after the service is added, earlier overrides never go up. CGM events (sensor and transmitter starts) were in the same position for Nightscout.

This adds both to uploadExistingData. Tidepool doesn't store CGM events yet (TidepoolService.uploadCgmEventData is a no-op), so for Tidepool the change only affects overrides.

…s added

uploadExistingData skipped both types, so a service added after Loop had been
running (for example Tidepool after Nightscout) didn't get the earlier
overrides or CGM events until the next override change or CGM event.
@ps2

ps2 commented Dec 5, 2026

Copy link
Copy Markdown
Collaborator Author

Tested in the Simulator with this branch (a02b5a1) and TidepoolService 272baa0, on existing data with Nightscout running and about 25k pump events:

  • Before adding Tidepool, ended two presets (Jogging after 39 s, Biking after 83 s), started Strength Training and left it active, and added a sensor start CGM event. Nothing touched overrides after that.
  • On adding Tidepool, every override went up with the initial upload: Jogging (which had been missing) with its 39 s duration, Strength Training (still active) with its planned 90 min, and Biking corrected to its actual 83 s.
  • The CGM event query ran and its anchor advanced with no errors. Tidepool stores nothing for it, as expected from the no-op upload.
  • Pump events uploaded in 25 batches of 1000 (with the TidepoolService fix) in about 5 s. No upload errors.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant